package com.ruoyi.company_Management.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.company_Management.domain.Qualification;
import com.ruoyi.company_Management.service.IQualificationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业资质Controller
 * 
 * @author why
 * @date 2025-04-26
 */
@RestController
@RequestMapping("/company_Management/qualification")
public class QualificationController extends BaseController
{
    @Autowired
    private IQualificationService qualificationService;

    /**
     * 查询企业资质列表
     */
    @PreAuthorize("@ss.hasPermi('company_Management:qualification:list')")
    @GetMapping("/list")
    public TableDataInfo list(Qualification qualification)
    {
        startPage();
        List<Qualification> list = qualificationService.selectQualificationList(qualification);
        return getDataTable(list);
    }

    /**
     * 导出企业资质列表
     */
    @PreAuthorize("@ss.hasPermi('company_Management:qualification:export')")
    @Log(title = "企业资质", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Qualification qualification)
    {
        List<Qualification> list = qualificationService.selectQualificationList(qualification);
        ExcelUtil<Qualification> util = new ExcelUtil<Qualification>(Qualification.class);
        util.exportExcel(response, list, "企业资质数据");
    }

    /**
     * 获取企业资质详细信息
     */
    @PreAuthorize("@ss.hasPermi('company_Management:qualification:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(qualificationService.selectQualificationById(id));
    }

    /**
     * 新增企业资质
     */
    @PreAuthorize("@ss.hasPermi('company_Management:qualification:add')")
    @Log(title = "企业资质", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Qualification qualification)
    {
        return toAjax(qualificationService.insertQualification(qualification));
    }

    /**
     * 修改企业资质
     */
    @PreAuthorize("@ss.hasPermi('company_Management:qualification:edit')")
    @Log(title = "企业资质", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Qualification qualification)
    {
        return toAjax(qualificationService.updateQualification(qualification));
    }

    /**
     * 删除企业资质
     */
    @PreAuthorize("@ss.hasPermi('company_Management:qualification:remove')")
    @Log(title = "企业资质", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qualificationService.deleteQualificationByIds(ids));
    }
}
